package com.atguigu.staservice.controller;

import com.atguigu.commonutils.R;
import com.atguigu.staservice.service.StatisticsDailyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-05-13
 */
@RestController
@RequestMapping("/edusta/statistics")
//@CrossOrigin //用nginx需要加
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService service;

    @ApiOperation("统计某天注册人数")
    @PostMapping("/registerCount/{day}")
    public R registerCount(@PathVariable("day") String day){
        service.registerCount(day);
        return R.ok();
    }
    @ApiOperation("获取统计数据")
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type") String type,@PathVariable("begin")String begin,@PathVariable("end")String end){
        Map<String,Object> map = service.showData(type,begin,end);
        return R.ok().data("date_calculatedList",map.get("date_calculatedList")).data("numDataList",map.get("numDataList"));
    }
}

